package com.gxa.employment.common;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;

/**
 * @Description: json转换工具类，就是封装的ObjectMapper的read和write方法
 * @Author:
 * @DateTime: 2025/3/18 16:52
 **/
public class JsonConvert {

    public static final ObjectMapper objectMapper = new ObjectMapper().registerModule(new JavaTimeModule());

    public static<T> T read(String json,Class<T> clazz) throws JsonProcessingException {
      return objectMapper.readValue(json,clazz);
    }

    public static String write(Object object) throws JsonProcessingException {
      return objectMapper.writeValueAsString(object);
    }
}
